﻿#region Copyright
/* Product of DTL Software
 * Product Name : Support Memmory
 * Author : dinhtienlam.spkt@gmail.com
 * About: Developer of DTL Software
 * Contact : 0966 330 237
 */
#endregion

#region Using default
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms.Design; 
#endregion

namespace Lamdt.Controls
{
    [Designer(typeof(LamdtGroupBoxControlDesigner))]
    public partial class LamdtGroupBox : UserControl
    {

        public LamdtGroupBox()
        {
            InitializeComponent();
            SetDefaultValue();
        }

        private void SetDefaultValue()
        {
            pnlHeaderParent.BackColor = Constants.LamdtColor.ForeColor;
            pnlWorkingParent.BackColor = Constants.LamdtColor.ForeColor;
        }

        [EditorBrowsable(EditorBrowsableState.Always)]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        [Bindable(true)]
        public override string Text
        {
            get
            {
                return base.Text;
            }

            set
            {
                this.lblCaption.Text = value;
                base.Text = value;
            }
        }

        [Category("Appearance")]
        public int ExtentHeaderGroup
        {
            set
            {
                pnlHeaderParent.Width += value;
                pnlHeader.Width = pnlHeaderParent.Width - 2;
                pnlHeaderTopRight.Location = new Point(pnlHeaderTopRight.Location.X + value, pnlHeaderTopRight.Location.Y);
                pnlHeaderParent.BringToFront();
                pnlHeader.BringToFront();
                pnlHeaderTopRight.BringToFront();
                pnlHeaderTopLeft.BringToFront();
                this.Refresh();
            }
        }

        [Category("Appearance")]
        public Font FontHeader
        {
            get
            {
                return lblCaption.Font;
            }
            set
            {
                lblCaption.Font = value;
            }
        }

        [Category("Appearance")]
        public Color HeaderColor
        {
            get
            {
                return lblCaption.ForeColor;
            }
            set
            {
                lblCaption.ForeColor = value;
            }
        }

        private ColorOption _coStyle = ColorOption.None;

        [Category("Appearance")]
        [DefaultValue(typeof(ColorOption), "None")]
        public ColorOption Style
        {
            get
            {
                return _coStyle;
            }
            set
            {
                _coStyle = value;
                if (value == ColorOption.White ||
                    value == ColorOption.None)
                {
                    pnlWorkingArea.BackColor = Color.White;
                    pnlHeader.BackColor = Color.White;
                    lblCaption.BackColor = Color.White;
                    lblCaption.ForeColor = Constants.LamdtColor.ForeColor;
                    pnlWorkingBottomLeft.BackgroundImage = global::Lamdt.Controls.Resource.WhiteContentBottom_Left;
                    pnlWorkingBottomRight.BackgroundImage = global::Lamdt.Controls.Resource.WhiteContentBottom_Right;
                    pnlWorkingTopRight.BackgroundImage = global::Lamdt.Controls.Resource.WhiteContentTop_Right;
                    pnlHeaderTopLeft.BackgroundImage = global::Lamdt.Controls.Resource.WhiteContentTop_Left;
                    pnlHeaderTopRight.BackgroundImage = global::Lamdt.Controls.Resource.WhiteContentTop_Right;
                }
                else
                {
                    pnlWorkingArea.BackColor = Constants.LamdtColor.ForeColor;
                    pnlHeader.BackColor = Constants.LamdtColor.ForeColor;
                    lblCaption.BackColor = Constants.LamdtColor.ForeColor;
                    lblCaption.ForeColor = Color.White;
                    pnlWorkingBottomLeft.BackgroundImage = global::Lamdt.Controls.Resource.BlueContentBottom_Left;
                    pnlWorkingBottomRight.BackgroundImage = global::Lamdt.Controls.Resource.BlueContentBottom_Right;
                    pnlWorkingTopRight.BackgroundImage = global::Lamdt.Controls.Resource.BlueContentTop_Right;
                    pnlHeaderTopLeft.BackgroundImage = global::Lamdt.Controls.Resource.BlueContentTop_Left;
                    pnlHeaderTopRight.BackgroundImage = global::Lamdt.Controls.Resource.BlueContentTop_Right;
                }
            }
        }

        [Browsable(false)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public Panel WorkingArea
        {
            get
            {
                return this.pnlWorkingArea;
            }
        }

        [Browsable(false)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public Panel TotalPanel
        {
            get { return this.pnlExtend; }
        }
    }

    public enum ColorOption
    {
        None,
        White,
        DarkBlue
    }
}
